<?php

require_once("functions.php");

//Connect To Database
dbConnect();

$Conference = array("AFC", "NFC");
$Division = array("East", "North", "South", "West");

foreach ($Conference as $confkey)
{
?>	
	<tr>
		<td><a href="http://www.nfl.com" class="permLink" target="blank"><img src="http://football.joshhughes.com/images/small/<?= $confkey; ?>.gif" alt="<?= $confkey; ?>" title="<?= $confkey; ?>" border="0" /></a></td>
	<?
	$count = 0;
	foreach ($Division as $divkey)
	{
		if($count < 4)
		{
			echo "<td>  <span style=\"color: #";
			if ($confkey == "AFC") {
				echo "FF0000";
			} else {
				echo "0000FF";
			}
			echo "\">|</span>	  </td>";
		}
		$count++;
		//Write SQL Query to extract specified data
		$SQL = "SELECT * FROM NFLTeams WHERE ((Conference = '".$confkey."') AND (Division = '".$divkey."')) ORDER BY TeamName";
		//Open Record Set using SQL Query
		$result = mysql_query($SQL) or die("Cannot query the database.<br>" . mysql_error());
		do{
			if (($myrow["TeamName"] != Null) || ($myrow["TeamName"] != ""))
			{
			?>
			<td align="center"><a href="<?= $myrow["URL"]; ?>" class="permLink" target="blank"><img src="http://football.joshhughes.com/images/small/<?= $myrow["TeamName"]; ?>.gif" alt="<?= $myrow["TeamName"]; ?>" title="<?= $myrow["TeamName"]; ?>" border="0" /></a> </td>
			<?
			}
		}while($myrow = mysql_fetch_array($result));
	}//end 

} //end FOR EACH ($Conference) LOOP
?>